package com.augurit.gzcgwsp.lhsp.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;

import com.augurit.common.util.PageUtils;
import com.augurit.gzcgwsp.lhsp.convert.LhspUpdateFlowResultConvert;
import com.augurit.gzcgwsp.lhsp.dao.LhspUpdateFlowResultDao;
import com.augurit.gzcgwsp.lhsp.entity.LhspUpdateFlowResult;
import com.augurit.gzcgwsp.lhsp.service.ILhspUpdateFlowResultService;
import com.augurit.gzcgwsp.lhsp.web.form.LhspUpdateFlowResultForm;
import com.augurit.wf.common.service.impl.WfBusClientServiceImpl;

/**
 * 接口五：提交办理结果材料  把数据传到并联审批系统
 * @author adm 
 *
 */
@Service
@Transactional
public class LhspUpdateFlowResultServiceImpl extends WfBusClientServiceImpl<LhspUpdateFlowResultForm>  implements ILhspUpdateFlowResultService {
	private static final Logger log=Logger.getLogger(LhspUpdateFlowResultServiceImpl.class);
	@Autowired
	private LhspUpdateFlowResultDao lhspSendCommandNoticeDao;
	
	/**
	 * 保存数据到数据库
	 * @param templateCode
	 * @param acceptNo 
	 * @param projectId 工程ID
	 * @param depId 部门编号，详见部门编号对照表
	 * @param resourceId 办理结果编号，详见办理结果对照表
	 * @param zjhpwbh  证件/批文的编号
	 * @param zjhpwmc 证件/批文的名称
	 * @param zjhpwyxqx 证件/批文有效期限，可空
	 * @return 
	 */
	public String saveLhspUpdateFlowResult(String templateCode,String acceptNo,String projectId,String depId,String resourceId,String zjhpwbh,String zjhpwmc,String zjhpwyxqx) throws Exception{
		LhspUpdateFlowResult lhspUpdateFlowResult = new LhspUpdateFlowResult();
		lhspUpdateFlowResult.setTemplateCode(templateCode);
		lhspUpdateFlowResult.setAcceptNo(acceptNo);
		lhspUpdateFlowResult.setProjectId(projectId);
		lhspUpdateFlowResult.setDepId(depId);
		lhspUpdateFlowResult.setResourceId(resourceId);
		lhspUpdateFlowResult.setZjhpwbh(zjhpwbh);
		lhspUpdateFlowResult.setZjhpwmc(zjhpwmc);
		lhspUpdateFlowResult.setZjhpwyxqx(zjhpwyxqx);
		lhspUpdateFlowResult.setProduceDate(new Date());
		this.save(lhspUpdateFlowResult);
		return null;
	}
	
	@Override
	public Page<LhspUpdateFlowResultForm> search(Page<LhspUpdateFlowResultForm> page,
			List<PropertyFilter> filters) {
		// TODO Auto-generated method stub
		return null;
	}
	/**
	 * 查询
	 * @param page 
	 * @param form 
	 * @return page
	 */
	public Page<LhspUpdateFlowResultForm> search(Page<LhspUpdateFlowResultForm> page,
			LhspUpdateFlowResultForm form) {
		Page pg = PageUtils.newPageInstance(page);
		StringBuffer hql = new StringBuffer("from LhspSendCommandNotice where 1=1");
		List values = new ArrayList();
		lhspSendCommandNoticeDao.findPage(pg, hql.toString(), values);		
		List<LhspUpdateFlowResultForm> list = LhspUpdateFlowResultConvert.convertVoListToFormList(pg.getResult());
		PageUtils.copy(pg, list, page);
		return page;
	
	}
	@Override
	public void delete(Long... ids) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public LhspUpdateFlowResultForm get(Long id) {
		LhspUpdateFlowResult entity = lhspSendCommandNoticeDao.get(id);
		LhspUpdateFlowResultForm form = LhspUpdateFlowResultConvert.convertVoToForm(entity);
		return form;
	}
	@Override
	public void save(LhspUpdateFlowResultForm... forms) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void save(LhspUpdateFlowResultForm forms) {
		// TODO Auto-generated method stub
		
	}
	public void save(LhspUpdateFlowResult lhspUpdateFlowResult){
		lhspSendCommandNoticeDao.save(lhspUpdateFlowResult);
	}

}
